package com.yunhe.policyfulfillment.task;

import com.yunhe.common.model.ResultObject;
import com.yunhe.policyfulfillment.policyful.service.PolicyCommonQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName PublishTimedTasks
 * @Description TODO
 * @Author HeTao
 * @Date 2021/8/2 10:15
 * @Version 1.0
 **/
@Api(value = "PublishTimedTasks",description = "定时发布",tags = "定时发布任务")
@RestController
@RequestMapping(value = "/publishTimed")
@Slf4j
public class PublishTimedTasks {

    @Autowired
    private PolicyCommonQuestionService policyCommonQuestionService;

    @ApiOperation("定时发布")
    @RequestMapping(value ="/publishTimed",method = RequestMethod.POST)
    @Scheduled(cron = "0 0 0/1 * * ? ")
    @Async
    public ResultObject publishTimed(){
        log.info("定时发布数据定时任务开始");
        //定时发布常见问题
        policyCommonQuestionService.publishTimedCommonQuestion();
        log.info("定时发布数据定时任务结束");
        return new ResultObject<>(null);
    }
}
